using System.Collections.Generic;
using Mgrs;
using UnityEngine;

namespace Datas
{
    [CreateAssetMenu(fileName = "PlayerData", menuName = "CustomData/玩家数据")]
    public class PlayerData : ScriptableObject
    {
        /**昵称 */
        private static string _name = "小小医徒";
        
        /**金钱 */
        private static int _money = 1000;
    
        /**声望 */
        private static int _prestige = 100;
        
        /**拥有卡牌集合 */
        private static readonly List<int> CardIds = new();

        /**初始化数据 */
        public static void InitData()
        {
            _money = 1000;
            _prestige = 100;
            _name = "小小医徒";
            
            CardIds.Clear();
            
            AddCardId((int)HerbEnum.Fuling);
            AddCardId((int)HerbEnum.GanCao);
            AddCardId((int)HerbEnum.ChaiHu);
            AddCardId((int)HerbEnum.JieGeng);
            AddCardId((int)HerbEnum.JieGeng);
            AddCardId((int)HerbEnum.AJiao);
        }

        /**获取玩家名 */
        public static string GetName()
        {
            return _name;
        }
        
        /**修改昵称 */
        public static void ChangeName(string name)
        {
            _name = name;
        }
        
        /**获取金钱值 */
        public static int GetMoney()
        {
            return _money;
        }
        
        /**修改金钱 */
        public static void ChangeMoney(int num)
        {
            _money += num;
            MsgMgr.Send(MsgData.ChangeMoney);
        }
        
        /**获取声望值 */
        public static int GetPrestige()
        {
            return _prestige;
        }
        
        /**修改声望值 */
        public static void ChangePrestige(int num)
        {
            _prestige += num;
            MsgMgr.Send(MsgData.ChangePrestige);
        }

        /**获取当前拥有的 卡牌id 集合 */
        public static List<int> GetCardIds()
        {
            return CardIds;
        }
        
        /**添加卡牌id */
        public static void AddCardId(int cardId)
        {
            CardIds.Add(cardId);
        }
        
        /**移除卡牌id */
        public static void RemoveCardId(int cardId)
        {
            CardIds.Remove(cardId);
        }

        /**游戏是否失败 */
        public static bool IsFail()
        {
            return _prestige <= 0;
        }
    }
}
